package com.linhh.mall.center.web.controller;

import com.github.pagehelper.PageInfo;
import com.linhh.mall.center.api.BrandInfoService;
import com.linhh.mall.center.common.pojo.BrandInfo;
import com.linhh.mall.center.common.util.HttpResult;
import org.apache.dubbo.config.annotation.Reference;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * BrandInfoController控制器
 * @Author linhh
 * @Date 2022 12 12 00 46
 **/
@RestController
@RequestMapping("/api")
public class BrandInfoController {
    @Reference
    private BrandInfoService brandInfoService;

    /**
     * 分页查询
     * @param pageNo
     * @param pageSize
     * @return
     */
    @GetMapping("/getBrand")
    public HttpResult getBrand(@RequestParam(value = "page",defaultValue = "1")int pageNo,@RequestParam(value = "pageSize",defaultValue = "10")int pageSize){
        PageInfo<BrandInfo> brands = brandInfoService.getBrand(pageNo+1,pageSize);
        return HttpResult.success(brands);
    }

    /**
     * 查询所有品牌信息
     * @return
     */
    @GetMapping("/getAllBrand")
    public HttpResult getAllBrand(){
        List<BrandInfo> all = brandInfoService.getAllBrand();
        return HttpResult.success(all);
    }
}
